/*
 * Copyright (C) 2024 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "imageknife_test.h"

namespace ImageKnifeTest {

napi_value MemoryCacheTest::MemoryCacheLimitTest(napi_env env, napi_callback_info info)
{
    const size_t argLength = 2;
    size_t argc = argLength;
    napi_value args[argLength];
    napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);

    int64_t maxSize = 0;
    int64_t maxUsage = 0;

    napi_get_value_int64(env, args[0], &maxSize);
    napi_get_value_int64(env, args[1], &maxUsage);

    auto & imageKnife = ImageKnifePro::ImageKnife::GetInstance(); 
    imageKnife.SetCacheLimit(ImageKnifePro::CacheStrategy::MEMORY, maxSize, maxUsage);
    napi_value result;
    napi_create_int64(env, imageKnife.GetCacheLimitSize(ImageKnifePro::CacheStrategy::MEMORY), &result);

    return result;
}

}